package com.JSXW.demo;

import java.util.Random;
import java.util.Scanner;

//public class RandomDemo {
//    public static void main(String[] args) {
//        Random random = new Random();
////        int count = random.nextInt(100); // 范围0-99, 包头不包尾
//        int count = random.nextInt(100) + 1; // 使用+1, 结果加1,范围1-100,
//        System.out.println(count);
//    }
//}
// 猜数字
public class RandomDemo {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int count = random.nextInt(5);
        int sam  = 0; // 保底
        while (true){ // 无限猜直到猜对为止
            sam ++;
            int scCount = scanner.nextInt();
            if (scCount == count) {
                sam = 0;
            } else if (sam == 3){
                System.out.println("猜对了");
                break;
            } else {
                System.out.println("猜错");
            }
        }
    }
}